package model.ability;

import model.core.Logger;
import model.entity.Entity;

public class Sleep extends InteractiveAbility {
	private int sleepDuration;
	/**
	 * Constructor for Sleep.
	 * @param name
	 * @param ps
	 * @param mana
	 * @param delay
	 */
	public Sleep(String name, PassiveSkill ps, int mana, int delay,
			int sleepDuration) {
		super(name, ps, mana, delay);
		this.sleepDuration = sleepDuration;
	}

	/**
	 * Sleep interaction - put the Entity to sleep for the
	 * given duration.  If it fails, the target becomes
	 * hostile.
	 */
	public void interactWithTarget(Entity caster, Entity target) {
		if(this.testProbability())
			this.putToSleep(target);
		else{
			target.makeHostile(caster);
			Logger.getInstance().writeToLogger("Ability failed!");
		}
	}

	/**
	 * Putting the Entity to sleep.
	 */
	private void putToSleep(Entity target){
		target.putToSleep(this.sleepDuration);
	}

}
